package deng.ejb3.examples.simplecase;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Stateless /* Expose this as CustomerDalBean/local JNDI binding. */
//@Stateless(name="MyCustomerDalBean")
//@Stateless(name="MyCustomerDalBean", mappedName="MyMappedCustomerDalBean") /* The mappedName take precedence over the bean name if it were use in a @EJB anno.! */
//@Stateless(name=Constants.EMPLOYEE_DAL_BEAN_LOCAL) /*WILL NOT WORK :(*/
public class EmployeeDalBean implements EmployeeDalLocal {
	
	private static Logger logger = LoggerFactory.getLogger(EmployeeDalBean.class);

	@PersistenceContext(unitName = Constants.EMPLOYEE_PERSISTENCE_UNIT)
	private EntityManager employeeEm;
	
	@Override
	public void insertCustomer(Employee employee) {
		logger.trace("Saving customer: " + employee);
		employeeEm.persist(employee);
		logger.debug("Customer saved: " + employee);
	}

}
